package com.ccb.sc.order.controller;

import com.ccb.sc.auth.TokenAuth;
import com.ccb.sc.auth.TokenModel;
import com.ccb.sc.order.controller.query.AppOrderCommonQueryParam;
import com.ccb.sc.order.service.IAppOrderService;
import com.ccb.sc.common.bind.annotation.CurrentUser;
import com.ccb.sc.common.bind.page.PageParams;
import com.ccb.sc.common.bind.page.PageVo;
import com.ccb.sc.common.bind.response.ResBody;
import com.ccb.sc.common.modules.order.enums.CommentStatus;
import com.ccb.sc.common.modules.order.enums.DeliverStatus;
import com.ccb.sc.common.modules.order.enums.OrderStatus;
import com.ccb.sc.common.modules.order.service.IOrderService;
import com.ccb.sc.common.modules.order.vo.OrderCommentListVo;
import com.ccb.sc.common.modules.order.vo.OrderListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author ken
 * @version 1.0
 * @date 2020-09-27
 */
@RestController
@TokenAuth
@RequestMapping("/app/comment-order")
@Api(value = "评价管理", tags = "评价管理")
public class AppCommentOrderController {

    private IAppOrderService appOrderService;
    private IOrderService orderService;

    @GetMapping("/wait")
    @ApiOperation(value = "待评价订单", response = OrderListVo.class, responseContainer = "list")
    public ResBody<?> wait(@CurrentUser @ApiIgnore TokenModel token, PageParams pageParams) {
        AppOrderCommonQueryParam commonQueryParam = new AppOrderCommonQueryParam();
        commonQueryParam.setStatus(OrderStatus.FINISHED);
        commonQueryParam.setDeliverStatus(DeliverStatus.RECEIVED);
        commonQueryParam.setCommentStatus(CommentStatus.WAIT_COMMENT);
        commonQueryParam.setCurrent(pageParams.getCurrent());
        commonQueryParam.setPageSize(pageParams.getPageSize());
        PageVo<OrderListVo> list = this.appOrderService.list(token.getId(), commonQueryParam);
        return ResBody.success(list);
    }

    @GetMapping("/finish")
    @ApiOperation(value = "已评价订单", response = OrderCommentListVo.class, responseContainer = "list")
    public ResBody<?> finish(@CurrentUser @ApiIgnore TokenModel token, PageParams queryParam) {
        PageVo<OrderCommentListVo> list = this.appOrderService.commentList(token.getId(), queryParam);
        return ResBody.success(list);
    }

    @Autowired
    public void setAppOrderService(IAppOrderService appOrderService) {
        this.appOrderService = appOrderService;
    }

    @Autowired
    public void setOrderService(IOrderService orderService) {
        this.orderService = orderService;
    }
}
